/**
 * Created by lijing on 2016-06-22.
 */
$.validator.setDefaults({
    submitHandler: function () {
        savePub();
    }
});
$(document).ready(function () {
    $("#file_upload").att({
        'scriptData': {
            'id': id,
        },
        'key': "user"
    });
    validate();

});
function validate() {
    //设置默认属性
    $("#mainForm").validate({
        rules: {
            userName: {
                required: true,
                minlength: 2
            },
            mobile: {
                required: true,
                minlength: 1
            }

        },
        messages: {
            userName: {
                required: "请输入用户名",
                minlength: "用户名必需由两个字母组成"
            },
            mobile: {
                required: "请输入手机号码",
                minlength: ""
            }
        }
    });
}
function savePub() {
    $.post(G_Path.path + "/user/save", $("#mainForm").serialize(), function (text) {
        var data = $.parseJSON(text);
        console.log(data);
        if (data.success) {
            if ("view" == status) {
                history.back();
            } else {
                window.close();
            }
        } else {
            showDialogMessage(data.msg);
        }
    });
}